#include<stdio.h>
	int main(void)
	{  
	  /*********Begin*********/
	  double x;
      scanf("%lf",&x);
      double ans=0;
      if(x<0 && x!=-3) ans=x*x+x-6;
      else if(0<=x && x<10) ans=x*x-5*x+6;
      else if(x>=10 || x==-3)ans=x*x-x-1;
      printf("%0.3lf",ans);
	  
	  /*********End**********/ 
       return 0;
	}
